﻿<views:MvxWpfView
	x:Class="Sidvall.WorkItemManager.UI.Wpf.Views.WorkConditionView"
	xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"  
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:views="clr-namespace:MvvmCross.Wpf.Views;assembly=MvvmCross.Wpf"
	xmlns:vms="clr-namespace:Sidvall.WorkItemManager.UI.ViewModels;assembly=Sidvall.WorkItemManager.UI"
	xmlns:Controls="clr-namespace:Sidvall.WorkItemManager.UI.Wpf.Controls" 
	xmlns:Converters="clr-namespace:Sidvall.UI.Wpf.Converters;assembly=Sidvall.UI.Wpf" 
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
	xmlns:local="clr-namespace:Sidvall.WorkItemManager.UI.Wpf.Views"
	xmlns:Converters1="clr-namespace:Sidvall.WorkItemManager.UI.Wpf.Converters" 
	mc:Ignorable="d" 
	d:DesignHeight="600" d:DesignWidth="800">

	<views:MvxWpfView.Resources>
		<Converters1:BooleanToWindowStateConverter x:Key="BooleanToWindowStateConverter"/>
		<Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
		<Converters:BooleanToVisibilityConverter x:Key="NotBooleanToVisibilityConverter" Not="True"/>
	</views:MvxWpfView.Resources>

	<Grid d:DataContext="{d:DesignInstance IsDesignTimeCreatable=True, Type={x:Type vms:WorkConditionViewModel}}">
		<Grid>
			<Grid.Background>
				<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.InactiveBorderColorKey}}"/>
			</Grid.Background>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition/>
				<RowDefinition Height="Auto" />
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="200" />
				<ColumnDefinition />
			</Grid.ColumnDefinitions>

			<Controls:HeaderControl Grid.ColumnSpan="2" HeaderCaption="Conditions" />

			<Grid Grid.Row="1">
				<Grid.Background>
					<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
				</Grid.Background>
				<StackPanel Orientation="Horizontal">
					<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.WorkItemManager.UI.Wpf;component/Images/Add.png" 
						ToolTip="Add" ButtonText="{Binding AddTreeItemCaption}" IsEnabled="{Binding CanAddTreeItem}" ButtonCommand="{Binding AddTreeItemCommand}" />
				</StackPanel>
			</Grid>
			<DataGrid x:Name="WorkerGrid" Grid.Row="2" Grid.RowSpan="2" ItemsSource="{Binding TreeItems}" AutoGenerateColumns="False" HeadersVisibility="None" CanUserReorderColumns="False" CanUserResizeColumns="False"
				CanUserResizeRows="False" CanUserSortColumns="False" SelectionMode="Single" CanUserAddRows="False" SelectedItem="{Binding ActiveTreeItem, Mode=TwoWay}" AllowDrop="True">
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="SelectionChanged">
						<i:InvokeCommandAction Command="{Binding SelectTreeItemCommand}" />
					</i:EventTrigger>
				</i:Interaction.Triggers>
				<DataGrid.Columns>
					<DataGridTemplateColumn Width="*">
						<DataGridTemplateColumn.CellTemplate>
							<DataTemplate>
								<Grid AllowDrop="True">
									<Grid Visibility="{Binding IsServer, Converter={StaticResource BooleanToVisibilityConverter}}" ToolTip="Server" Background="#FF6AA8C5">
										<Grid.RowDefinitions>
											<RowDefinition Height="40" />
										</Grid.RowDefinitions>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="40" />
											<ColumnDefinition />
										</Grid.ColumnDefinitions>
										<Image Margin="5" Source="/Sidvall.WorkItemManager.UI.Wpf;component/Images/Server.png" Stretch="UniformToFill" />
										<TextBlock Grid.Column="1" Text="{Binding Name}" FontWeight="Bold" Margin="5,0,0,0" VerticalAlignment="Center" FontSize="14" ToolTip="{Binding ItemTooltip}" ForceCursor="False" />
									</Grid>
									<Grid Visibility="{Binding IsItem, Converter={StaticResource BooleanToVisibilityConverter}}" ToolTip="Task type">
										<Grid.RowDefinitions>
											<RowDefinition Height="30" />
										</Grid.RowDefinitions>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="30" />
											<ColumnDefinition />
										</Grid.ColumnDefinitions>
										<Image Margin="5" Source="/Sidvall.WorkItemManager.UI.Wpf;component/Images/WorkItemType.png" Stretch="UniformToFill" />
										<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="5,0,0,0" VerticalAlignment="Center" ToolTip="{Binding ItemTooltip}" Visibility="{Binding IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" />
										<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="5,0,0,0" VerticalAlignment="Center" ToolTip="{Binding ItemTooltip}" Visibility="{Binding IsEnabled, Converter={StaticResource NotBooleanToVisibilityConverter}}" Opacity="0.2" />
									</Grid>
								</Grid>
							</DataTemplate>
						</DataGridTemplateColumn.CellTemplate>
					</DataGridTemplateColumn>
				</DataGrid.Columns>
			</DataGrid>

			<Grid Grid.Row="1" Grid.Column="1">
				<Grid.Background>
					<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
				</Grid.Background>
				<StackPanel Orientation="Horizontal">
					<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.WorkItemManager.UI.Wpf;component/Images/Save.png" 
						ToolTip="Save" ButtonCommand="{Binding SaveActiveTreeItemCommand}" IsEnabled="{Binding CanSave}" />
					<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.WorkItemManager.UI.Wpf;component/Images/Refresh.png" 
						ToolTip="Reload" ButtonCommand="{Binding SelectTreeItemCommand}" IsEnabled="{Binding CanSave}" />
					<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.WorkItemManager.UI.Wpf;component/Images/Delete.png" 
						ToolTip="Remove" ButtonCommand="{Binding DeleteActiveTreeItemCommand}" IsEnabled="{Binding CanDelete}" />
					<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.WorkItemManager.UI.Wpf;component/Images/Export.png" 
										ToolTip="Export" ButtonCommand="{Binding ExportSettingsCommand}" IsEnabled="{Binding CanDelete}" />
					<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.WorkItemManager.UI.Wpf;component/Images/Import.png" 
										ToolTip="Import" ButtonCommand="{Binding ImportSettingsCommand}" IsEnabled="{Binding CanAddTreeItem}" />
				</StackPanel>
			</Grid>
			<Grid Grid.Row="2" Grid.Column="1" Grid.RowSpan="2">
				<Grid.RowDefinitions>
					<RowDefinition/>
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition />
				</Grid.ColumnDefinitions>

				<Grid Grid.RowSpan="2" Visibility="{Binding InformationIsVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
					<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" FontWeight="Bold"><Run Text="Select item"/></TextBlock>
				</Grid>

				<Grid Visibility="{Binding ServerIsVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
					<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20"><Run Text="Server"/></TextBlock>
				</Grid>

				<Grid Visibility="{Binding ItemIsVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
						<RowDefinition />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition />
					</Grid.ColumnDefinitions>

					<Grid Grid.Row="1">
						<StackPanel IsEnabled="{Binding CanEdit}">
							<Grid Margin="5,5,5,0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="130" />
									<ColumnDefinition Width="130" />
									<ColumnDefinition />
								</Grid.ColumnDefinitions>

								<Label Content="Id"/>
								<TextBox Grid.Column="1" Text="{Binding ActiveItem.WorkConditionId, Mode=OneWay}" IsReadOnly="True" />
							</Grid>
							<Grid Margin="5,5,5,0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="130" />
									<ColumnDefinition />
								</Grid.ColumnDefinitions>

								<Label Content="Name"/>
								<TextBox Grid.Column="1" Text="{Binding ActiveItem.Name}" />
							</Grid>
							<Grid Margin="5,5,5,0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="130" />
									<ColumnDefinition />
								</Grid.ColumnDefinitions>

								<Label Content="Description"/>
								<TextBox Grid.Column="1" Height="60" Text="{Binding ActiveItem.Description}" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" />
							</Grid>
							<Grid Margin="5,5,5,0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="130" />
									<ColumnDefinition />
									<ColumnDefinition Width="Auto" />
								</Grid.ColumnDefinitions>

								<Label Content="Worker"/>
								<TextBox Grid.Column="1" ToolTip="Class that impleents Sidvall.WorkItemManager.Workflow.IWorkItemProvider" Text="{Binding ActiveItem.Codename}" TextWrapping="Wrap" Height="40" VerticalScrollBarVisibility="Visible" />
							</Grid>
							<Grid Margin="5,5,5,0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="130" />
									<ColumnDefinition />
									<ColumnDefinition Width="Auto" />
								</Grid.ColumnDefinitions>

								<Label Content="Context Editor"/>
								<TextBox Grid.Column="1" ToolTip="Class that implements using MvvmCross.Core.ViewModels;.IMvxViewModel" Text="{Binding ActiveItem.ContextEditor}" TextWrapping="Wrap" Height="40" VerticalScrollBarVisibility="Visible" />
							</Grid>
						</StackPanel>
					</Grid>
				</Grid>
			</Grid>
		</Grid>
	</Grid>
</views:MvxWpfView>
